﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;

using System.ComponentModel;
using System.Windows.Threading;

namespace PermDoc
{
    public partial class Welcome : Page
    {

        #region Members
        private bool IsInit = false;
        protected static DispatcherTimer _timer_idle = new DispatcherTimer();
        private Uri _WelcomeUri = new Uri(@"/Welcome.xaml", UriKind.Relative);
        #endregion

        #region Constructor
        public Welcome()
        {
            InitializeComponent();
            oDocCountTotal_new.DataContext = App.oInfoPanelData;
            oDocCountToDay_new.DataContext = App.oInfoPanelData;
            oDocCountYesterDay_new.DataContext = App.oInfoPanelData;
            oDocCountLastWeek_new.DataContext = App.oInfoPanelData;
            oDocCountLastMonth_new.DataContext = App.oInfoPanelData;
            oDocCountTotal_edt.DataContext = App.oInfoPanelData;
            oDocCountToDay_edt.DataContext = App.oInfoPanelData;
            oDocCountYesterDay_edt.DataContext = App.oInfoPanelData;
            oDocCountLastWeek_edt.DataContext = App.oInfoPanelData;
            oDocCountLastMonth_edt.DataContext = App.oInfoPanelData;
            oBeforeCreated.DataContext = App.oInfoPanelData;
            oInvalidateCountCurDay.DataContext = App.oInfoPanelData;
            oInvalidateCountTotal.DataContext = App.oInfoPanelData;
            App.WelcomePagePtr = this;
        }
        #endregion

        #region Page Events
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            App.IdleEmpty();
            App.WelcomePagePtr = this;
            _timer_idle.Tick += new EventHandler(myTimer_Idle);
            _timer_idle.Interval = new TimeSpan(0, 0, 1);
            _timer_idle.Start();

            IsInit = true;
        }
        private void Page_Unloaded(object sender, RoutedEventArgs e)
        {
            _timer_idle.Stop();
            App.WelcomePagePtr = null;
            IsInit = false;
        }
        private void Page_MouseMove(object sender, MouseEventArgs e)
        {
            App.IdleEmpty();
            InvalidateProgressCtrl();
        }
        void myTimer_Idle(object sender, EventArgs e)
        {
            InvalidateProgressCtrl();
            if (App.Idle > App._idleMax)
            {
            }
        }
        #endregion

        #region Controls Events
        private void InvalidateProgressCtrl()
        {
            if (App.isProcessGetData == true)
                oEye.Visibility = System.Windows.Visibility.Visible;
            else
                oEye.Visibility = System.Windows.Visibility.Collapsed;
        }
        #endregion

    }
}
